-
Notifications
You must be signed in to change notification settings - Fork 714
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
canlogserver: Close accsocket and can when tcp client disconnected #149
base: master
Are you sure you want to change the base?
Conversation
Close all can socket and send "FYI" to tcp client when the tcp client disconnected. Signed-off-by: qianfan Zhao <[email protected]>
What problem do you want to solve? |
@hartkopp Hi, please try this patch: Open canlogserver and 'telnet' it in another computer, disconnect tcp link in the client right now. (canlogserver IP: 10.11.12.13, tcp client IP: 10.11.12.1)
canlogserver doesn't close the tcp link when the client disconnected. (There are no FYI sent from server). If the can interface got a frame after the tcp client disconnected, canlogserver try write this frame to tcp client. It will got a RST.
But canlogserver doesn't know the client disconnected, it think this can frame was sent successfully.
The next time when it try sent another can frame, it will got signal PIPE and died due to without signal handler.
The tcp logic seems not good. |
Hi, I've been reading canlogserver.c thease days. And indeed it does some odd thing. The code structure is basicall,
When a new client connects, For new child, enumerate the list of can interfaces and open them again. I'd propose
Optionally,
The first part goes something like: diff --git a/canlogserver.c b/canlogserver.c
index 3fe1ad9..6e7b137 100644
--- a/canlogserver.c
+++ b/canlogserver.c
@@ -424,9 +424,10 @@ int main(int argc, char **argv)
sprint_canframe(temp+strlen(temp), &frame, 0, maxdlen);
strcat(temp, "\n");
- if (write(accsocket, temp, strlen(temp)) < 0) {
- perror("writeaccsock");
- return 1;
+ if (send(accsocket, temp, strlen(temp), MSG_NOSIGNAL) < 0) {
+ //perror("writeaccsock");
+ running = 0;
+ break;
}
#if 0 WDYT? |
Close all can socket and send "FYI" to tcp client when the tcp client
disconnected.
Signed-off-by: qianfan Zhao [email protected]